package org.abc.fund.controller.trade.response;

import lombok.Builder;
import lombok.Data;
import org.abc.fund.entity.trade.TradeOrder;
import org.abc.fund.entity.trade.TradeOrderDetail;

import java.math.BigDecimal;

@Data
@Builder
public class TradeOrderDetailResponse {
  private Long id;
  private String fundCode;
  private TradeOrderDetail.Direction direction;
  private BigDecimal amount;
  private TradeOrder.TradeStatus status;

  public static TradeOrderDetailResponse fromEntity(TradeOrderDetail tradeOrderDetail) {
    return TradeOrderDetailResponse.builder()
        .id(tradeOrderDetail.getId())
        .fundCode(tradeOrderDetail.getFund().getCode())
        .direction(tradeOrderDetail.getDirection())
        .amount(tradeOrderDetail.getAmount())
        .status(tradeOrderDetail.getStatus())
        .build();
  }
}
